<template>
  <div class="express-table-item" v-if="currExpress.id>0">
    <div class="sender-box">
      <div class="city-name" v-text="getCity('sender')"></div>
      <div class="real-name" v-text="currExpress.senderName"></div>
    </div>
    <div class="status-box">
      <div class="status-icon" :class="getStatusClass()"></div>
      <div class="status-name" v-text="currExpress.tagName">

      </div>
      <div class="status-time">
        (<span v-text="currExpress.updatedTime"></span>)
      </div>
    </div>
    <div class="receiver-box">
      <div class="city-name" v-text="getCity('receiver')"></div>
      <div class="real-name" v-text="currExpress.receiverName"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ExpressTableItem',
  props:{
    currExpress:Object
  },
  methods: {
    getStatusClass:function () {
      var tagNameArr=['已揽件','配送中','派送中','已签收'];
      var index = tagNameArr.indexOf(this.$props.currExpress.tagName)
      if (index===-1){
        index=1
      }
      return 'status-'+index
    },
    getCity:function (type) {
      var addressDetail=''
      if (type==='sender'){
        addressDetail=this.$props.currExpress.senderAddress
      }else{
        addressDetail=this.$props.currExpress.receiverAddress
      }
      var addressDetailArr=addressDetail.split(',')
      return addressDetailArr[1]
    }
  }
}
</script>

<style scoped>

</style>
